﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace IRIS.Models
{
    public class DataRepo
    {
        IRISentityDataContext m_db = new IRISentityDataContext();
        
        public void Add(Content the_Content)
        {
            m_db.Contents.InsertOnSubmit(the_Content);
            m_db.SubmitChanges();
        }
        public IEnumerable<Content> getArticles()
        {
            var result = from c in m_db.Contents
                         where c.Alive == true && c.News == false
                         orderby c.Created descending
                         select c;
            return result;
        }
        
        public IEnumerable<Content> getNews()
        {
            var result = from c in m_db.Contents
                       where c.Alive == true && c.News == true
                       orderby c.Created descending
                       select c;
            return result;
        }
        public IEnumerable<ContentCategory> getContentCategories()
        {
            var result = from c in m_db.ContentCategories
                         where c.Alive == true
                         select c;
            return result;
        }
        public IEnumerable<Link> getLinks()
        {
            var result = from c in m_db.Links
                       where c.Alive == true
                       select c;
            return result;
        }
        public IEnumerable<LinkCategory> getLinkCategories()
        {
            var result = from c in m_db.LinkCategories
                       where c.Alive == true
                       select c;
            return result;
        }
        public IEnumerable<Poll> getPolls()
        {
            var result = from c in m_db.Polls
                       where c.Alive == true
                       select c;
            return result;
        }
        public IEnumerable<Newsletter> getNewsletters()
        {
            var result = from c in m_db.Newsletters
                       select c;
            return result;
        }
        public IEnumerable<Sponsor> getSponsors()
        {
            var result = from c in m_db.Sponsors
                         where c.Alive == true
                         select c;
            return result;
        }
        public IEnumerable<EventCal> getEventCals()
        {
            var result = from c in m_db.EventCals
                         where c.Alive == true
                         select c;
            return result;
        }
        public IEnumerable<FAQ> getFAQs()
        {
            var result = from c in m_db.FAQs
                         where c.Alive == true
                         select c;
            return result;
        }
    }
}